<template>
  <div class="qr-container">

    <div class="nav-bar">
      <button class="back-btn" @click="goBack">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none">
          <path d="M15 18l-6-6 6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round"
            stroke-linejoin="round" />
        </svg>
      </button>
    </div>

    <!-- Header Section -->
    <div class="header-section">
      <div class="token-info">
        <div class="token-icon">
          <!-- <span class="usdt-icon">₮</span> -->
          <img src="../assets/USDT.png" alt="">
        </div>
        <div class="token-details">
          <h1 class="token-name">USDT</h1>
          <p class="wallet-address">{{ pageValue }}</p>
        </div>
      </div>
    </div>
    <!--  -->
    <div class="line" style="height: 1px; background-color: transparent;margin: 10px 30px;opacity: 0.5;"></div>
    <!-- Warning Message -->
    <div class="warning-section">
      <p class="warning-text">仅支持接收 TRON 网络资产</p>
    </div>

    <!-- QR Code Section -->
    <div class="qr-section">
      <QRCodeVue3 :width="qrSize" :height="qrSize" :value="qrValue"
        :qrOptions="{ typeNumber: 0, mode: 'Byte', errorCorrectionLevel: 'H' }" :dotsOptions="{
          type: 'dots',
          color: '#000000',
        }" :cornersSquareOptions="{
          type: 'dot',
          color: '#000000'
        }" :cornersDotOptions="{
          type: 'dot',
          color: '#000000'
        }" :backgroundOptions="{ color: '#ffffff' }" />
    </div>


    <!-- Footer Section -->
    <div class="footer-section">
      <div class="footer-content">
        <div class="footer-left">
          <div class="web3-icon1">
            <img src="../assets/logo.png" style="border: 1px solid #292929;
    border-radius: 6px;
    width: 50px;
    height: 50px;" alt="">
          </div>
          <div class="footer-text">
            <span class="web3-title">Web3 钱包</span>
            <span class="website">okx.com/web3</span>
          </div>
        </div>
        <!-- style="border-radius: 8px; overflow: hidden;" -->
        <div   style="
         width: 70px;
      height: 70px;
      border-radius: 4px;
      overflow: hidden;">
          <QRCodeVue3 :width="70" :height="70" :value="qrValue" :qrOptions="{
            typeNumber: 0,
            mode: 'Byte',
            errorCorrectionLevel: 'H'
          }" :dotsOptions="{
            type: 'dots',
            color: '#000000'
          }" :cornersSquareOptions="{
          type: 'extra-rounded', // 或 'dot'，看具体效果
          color: '#000000'
        }" :cornersDotOptions="{
          type: 'dot',
          color: '#000000'
        }" :backgroundOptions="{ color: '#ffffff' }" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, nextTick, onMounted } from 'vue'
import QRCodeVue3 from 'qrcode-vue3'
import { useRouter } from 'vue-router'
import { contractinfo } from '@/api/index.js'


const router = useRouter()
const qrValue = ref("https://bing.com/")
const pageValue = ref('TMYDoZXzRP8NDwWabGsD2JTrrcz5XWyK')
const qrSize = ref(250)

const contractinfoApi = (async () => {
  let { data } = await contractinfo()
  console.log(data,'dataa');
  
  let address = data.address
  pageValue.value = address
  qrValue.value = import.meta.env.VITE_BASE_URL + '?=address' + address
})


onMounted(async () => {
  await nextTick()
  await contractinfoApi()
})

const goBack = () => {
  router.go(-1)
}
</script>

<style scoped>
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #fff;
}

.back-btn,
.expand-btn {
  background: none;
  border: none;
  /* padding: 8px; */
  cursor: pointer;
  color: #333;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.back-btn:hover,
.expand-btn:hover {
  background-color: #f0f0f0;
}


.qr-container {
  min-height: 100vh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  max-width: 375px;
  margin: 0 auto;
  position: relative;
}

/* Header Section */
.header-section {
  /* padding: 40px 24px 0px; */
  padding: 0px 24px;
  /* border-bottom: 1px solid #BEC2C1; */
  text-align: center;
}

.token-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.token-icon {
  width: 48px;
  height: 48px;
  background: #26D0CE;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(38, 208, 206, 0.2);
  flex-shrink: 0;
}

.usdt-icon {
  color: white;
  font-size: 24px;
  font-weight: bold;
}

.token-details {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.token-name {
  font-size: 16px;
  font-weight: 600;
  /* color: #1a1a1a; */
  color: #1C1C1C;
  margin: 0 0 8px 0;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.wallet-address {
  font-size: 12px;
  /* color: #666666; */
  color: #BEC2C1;
  font-family: 'Monaco', 'Menlo', monospace;
  word-break: break-all;
  line-height: 1.4;
  margin: 0;
  max-width: 250px;
  /* max-width: 280px; */
}

/* Warning Section */
.warning-section {
  /* padding: 0 24px 24px; */
  text-align: center;
}

.warning-text {
  font-size: 14px;
  /* color: #999999; */
  color: #CACACA;
  margin: 0;
  font-weight: 400;
}

/* QR Code Section */
.qr-section {
  height: 300px;
  /* flex: 1; */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.qr-code-wrapper {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 24px;
}

.qr-code {
  width: 240px;
  height: 240px;
  background: white;
  position: relative;
  border: 1px solid #f0f0f0;
}

.qr-pattern {
  width: 100%;
  height: 100%;
  position: relative;
  background-image:
    radial-gradient(circle at 20% 20%, #000 2px, transparent 2px),
    radial-gradient(circle at 40% 20%, #000 2px, transparent 2px),
    radial-gradient(circle at 60% 20%, #000 2px, transparent 2px),
    radial-gradient(circle at 80% 20%, #000 2px, transparent 2px),
    radial-gradient(circle at 20% 40%, #000 2px, transparent 2px),
    radial-gradient(circle at 40% 40%, #000 2px, transparent 2px),
    radial-gradient(circle at 60% 40%, #000 2px, transparent 2px),
    radial-gradient(circle at 80% 40%, #000 2px, transparent 2px),
    radial-gradient(circle at 20% 60%, #000 2px, transparent 2px),
    radial-gradient(circle at 40% 60%, #000 2px, transparent 2px),
    radial-gradient(circle at 60% 60%, #000 2px, transparent 2px),
    radial-gradient(circle at 80% 60%, #000 2px, transparent 2px),
    radial-gradient(circle at 20% 80%, #000 2px, transparent 2px),
    radial-gradient(circle at 40% 80%, #000 2px, transparent 2px),
    radial-gradient(circle at 60% 80%, #000 2px, transparent 2px),
    radial-gradient(circle at 80% 80%, #000 2px, transparent 2px);
  background-size: 12px 12px;
}

.qr-corner {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 6px solid #000;
}

.qr-corner::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 12px;
  width: 18px;
  height: 18px;
  background: #000;
}

.qr-corner-tl {
  top: 12px;
  left: 12px;
}

.qr-corner-tr {
  top: 12px;
  right: 12px;
}

.qr-corner-bl {
  bottom: 12px;
  left: 12px;
}

.qr-corner-br {
  bottom: 12px;
  right: 12px;
}

/* Footer Section */
.footer-section {
  background: #000000;
  padding: 16px 24px;
  margin-top: auto;
  margin-bottom: 30px;
  border-bottom-right-radius: 11px;
  border-bottom-left-radius: 11px;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.web3-icon {
  width: 32px;
  height: 32px;
  position: relative;
}

.icon-squares {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 100%;
  height: 100%;
}

.square {
  background: white;
  border-radius: 2px;
}

.footer-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.web3-title {
  /* color: white; */
  color: #F2F2F2;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.2;
}

.website {
  /* color: #666666; */
  color: #F2F2F2;
  font-size: 11px;
  line-height: 1.2;
}

.footer-qr {
  width: 32px;
  height: 32px;
}

.mini-qr {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 4px;
  position: relative;
  background-image:
    radial-gradient(circle at 25% 25%, #000 1px, transparent 1px),
    radial-gradient(circle at 75% 25%, #000 1px, transparent 1px),
    radial-gradient(circle at 25% 75%, #000 1px, transparent 1px),
    radial-gradient(circle at 75% 75%, #000 1px, transparent 1px);
  background-size: 8px 8px;
}
</style>